package API.DAY10.reflect;

import java.lang.reflect.Constructor;

public class ReflectDemo3 {
    public static void main(String[] args) throws Exception{
        Person p = new Person();
        System.out.println(p);

        Class cls = Class.forName("API.DAY10.reflect.Person");

        Constructor c = cls.getConstructor(String.class);
        Object obj = c.newInstance("mjj");
        System.out.println(obj);

        Constructor c2 = cls.getConstructor(String.class,int.class);
        Object obj2 = c2.newInstance("mjj",21);
        System.out.println(obj2);
    }
}
